<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>


    <title>注册</title>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>

    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">


    <!-- import Vue before Element -->
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <!-- import JavaScript -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style>
        html{
            height: 100%;
        }
        .conDiv{
            width: 300px;
            margin: auto;
            margin-top:200px;
            text-align: center;
        }
        .form-group{
            margin: 10px auto;
        }
        .form-group input{
            width: 200px;
            height: 30px;
            border-radius: 4px;
            padding-left: 5px;
            border: 1px solid #fff;
        }
        .conDiv button{
            width: 205px;
            height: 35px;
            background-color: green;
            border: 1px solid green;
            border-radius: 4px;
            text-align: center;
            color: #fff;
            font-size: 14px;
            cursor: pointer;
        }
        .register{
            margin-top: 10px;
            cursor: pointer;
            color: #fff;
            text-decoration: underline;
        }
    </style>

</head>

<body class="gray-bg" style="background-image:url(static/img/loginBGI.jpg);background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;">
<!--    sessionguoqichongdingxiang-->
    <div id="loginApp" style="height:100%;">
        <div style="height:100%;" v-loading="fullscreenLoading" element-loading-text="拼命注册中">
            <div class="conDiv">
                <div>
                    <div>
                        <img src="static/img/loginLogo.png"/>
                    </div>
                    <form style="margin-top:50px;">
                        <div class="form-group">
                            <input type="text" id="account" class="form-control ipt" placeholder="账号" required="" autofocus="autofocus" />
                        </div>
                        <div class="form-group">
                            <input type="password" id="password" class="form-control ipt" placeholder="密码" required=""/>
                        </div>
                        <div class="form-group">
                            <input type="text" id="name" class="form-control ipt" placeholder="参赛队名" />
                        </div>
                        <button type="button" @click="login">注 册</button>
                        <div @click="goLogin" class="register">去登录</div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</body>

        <script>if(window.top !== window.self){ window.top.location = window.location;}</script>

    <!-- 全局js -->
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
	<script>
        window.onload=function(){
            $("#account").focus();
            document.onkeydown=function(e){
                // 兼容FF和IE和Opera
                var theEvent = e || window.event;
                var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
                if (code == 13 && loginApp.$data.flag) {
                  //回车执行登录
                    loginApp.login();
                }else if(code == 13){
                    loginApp.$data.flag=true;
                }
            }
        }

        function getContextPath(){
            var localObj = window.location;
            var contextPath = localObj.pathname.split("/")[1];
            return contextPath ;
        }

                    var basePath = "/"+getContextPath();
        var loginApp=new Vue({
            el:"#loginApp",
            data(){
                return {
                    fullscreenLoading:false,
                    sex:1,
                    flag:true
                }
            },
            mounted(){

            },
            methods:{
                goLogin(){
                    window.location.href=basePath+"/idx_login";
                },
                login(){
                    this.fullscreenLoading=true;
                    var user = $("#account").val();
                    var password = $("#password").val();
                    var name = $("#name").val();
                    let that=this;
                    $.ajax({
                        type: "get",
                        url: basePath+"/user/addSystemUser",
                        async: false,
                        data: {USERNAME:user,PASSWORD:password,NAME:name},
                        success: function (data)
                        {

                            if(data.status == 0){
                                that.$message({
                                  message: '注册成功!',
                                  type: 'success'
                                });
                            }else{
                                that.$message({
                                    message: data.msg,
                                    type: 'error'
                                });
                            }
                            that.fullscreenLoading=false;
                        }
                     });
                }
            }
        })

    </script>
</html>
